﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interop;
using System.Runtime.InteropServices;
using Bainx.WPF.Extend;

namespace Bainx.WPF.Extend.Struct
{
    /// <summary>
    /// 用于创建MenuItem的一种结构
    /// </summary>
    public struct MenuSource
    {
        /// <summary>
        /// 显示的文本
        /// </summary>
        public object Header;
        /// <summary>
        /// 用于MenuItem的Click事件处理方法
        /// </summary>
        public RoutedEventHandler EventFunction;
        /// <summary>
        /// 样式
        /// </summary>
        public Style Style;
        /// <summary>
        /// 用于创建MenuItem的一种结构
        /// </summary>
        /// <param name="header"></param>
        /// <param name="eventFunction"></param>
        /// <param name="style"></param>
        public MenuSource(object header, RoutedEventHandler eventFunction, Style style)
        {
            Header = header;
            EventFunction = eventFunction;
            Style = style;
        }
        /// <summary>
        /// MenuSource 转换成MenuItem
        /// </summary>
        /// <returns></returns>
        public MenuItem ToMenuItem()
        {
            MenuItem ret = new MenuItem();
            ret.Header = Header;
            ret.Click += EventFunction;
            ret.Style = Style;
            return ret;
        }
    }
}
